package com.example.shiro_springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shiro_springboot.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper extends BaseMapper<User> {
    @Select("select name from role where id in (select rid from role_user where uid=(select id from user where name=#{principal}))")
    List<String> getUserRoleInfoMapper(@Param("principal")String username);
    @Select({
            "<script>",
            "select info from permissions where id in ( " ,
                    " select pid from role_ps where rid in ( " ,
                    " select id from role where name in ",
            "<foreach collection='roles' item='name' open='(' separator=',' close=')' >",
            "#{name}",
            "</foreach>",
            "))",
            "</script>"
    })
    List<String> getPermissionInfoMapper(@Param("roles")List<String> roleList);
}
